package com.woollen.controller;

import com.woollen.common.BaseResponse;
import com.woollen.common.ResultUtils;
import com.woollen.model.Member;
import com.woollen.model.dto.MemberLoginRequest;
import com.woollen.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @PostMapping("/login")
    public BaseResponse<Member> login(@RequestBody MemberLoginRequest req) {
        if (req == null || req.getPhoneOrEmail() == null || req.getPassword() == null) {
            throw new IllegalArgumentException("账号或密码不能为空");
        }
        Member admin = adminService.login(req.getPhoneOrEmail(), req.getPassword());
        return ResultUtils.success(admin);
    }
} 